import {
	WFDynaEditView3ActionType,
	IWFDynaEditView3Ability,
	IWFDynaEditView3ControllerParams,
	IWFDynaEditView3Model,
	IWFDynaEditView3Store,
	IParam,
	IViewEvent,
	IWFDynaEditView3Controller,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
	useViewProps,
} from '../use-view';

/**
 * 获取动态工作流编辑3视图输入参数
 *
 * @export
 * @return {*}
 */
export function useWFDynaEditView3Props() {
	return {
		...useViewProps(),
	};
}

/**
 * 获取动态工作流编辑3视图基础
 *
 * @export
 * @param {IWFDynaEditView3Model} model 动态工作流编辑3视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useWFDynaEditView3Basic(
	model: IWFDynaEditView3Model,
	props: IParam
) {
	const getClassNames = (props: IParam) => {
		return getViewClassNames(model, props);
	};
	return {
		...useViewBasic(model, props),
		getClassNames,
	};
}

/**
 * 动态工作流编辑3视图行为
 *
 * @export
 */
export function useWFDynaEditView3Action(controller: any) {
	const handleActionClick = (event: MouseEvent, item: IParam) => {
		controller.handleActionClick(event, item);
	};
	const handleDynamicToolbarClick = (item: IParam) => {
		controller.handleDynamicToolbarClick(item);
	};
	const handleToolbarItemClick = (
		controller: IWFDynaEditView3Controller<
			IWFDynaEditView3Store,
			IWFDynaEditView3Ability
		>,
		name: string,
		event: MouseEvent,
		logic: any
	) => {
		controller.handleToolbarItemClick(event, logic);
	};
	return {
		...useViewAction(controller),
		handleActionClick,
		handleDynamicToolbarClick,
		handleToolbarItemClick,
	};
}

/**
 * 获取动态工作流编辑3视图控制器输入参数
 *
 * @export
 * @param {IWFDynaEditView3Model} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<WFDynaEditView3ActionType, IWFDynaEditView3Ability>>} evt
 * @return {*}  {IWFDynaEditView3ControllerParams<WFDynaEditView3ActionType, IWFDynaEditView3Ability>}
 */
export function useWFDynaEditView3ControllerParams(
	model: IWFDynaEditView3Model,
	props: IParam,
	evt: QXEvent<IViewEvent<WFDynaEditView3ActionType, IWFDynaEditView3Ability>>
): IWFDynaEditView3ControllerParams<
	WFDynaEditView3ActionType,
	IWFDynaEditView3Ability
> {
	return {
		...useViewControllerParams<IWFDynaEditView3Store, IWFDynaEditView3Model>(
			model,
			props,
			evt
		),
	};
}
